﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel.Description;

namespace IndexMarkWcfService
{
    class CacheAttribute : Attribute, IOperationBehavior
    {
        private CacheInvokerBase Invoker;

        public CacheAttribute()
        {

        }

        public CacheAttribute(Type InvokerType)
        {
            Invoker = Activator.CreateInstance(InvokerType) as CacheInvokerBase;
        }

        #region IOperationBehavior Members

        public void AddBindingParameters(OperationDescription operationDescription, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
        {
        }

        public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
        {
        }

        public void ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
        {
            Invoker.BaseInvoker = dispatchOperation.Invoker;
            dispatchOperation.Invoker = Invoker;
        }

        public void Validate(OperationDescription operationDescription)
        {

        }

        #endregion
    }
}
